from django.db import models


class Department(models.Model):
    """部门表"""
    title = models.CharField(verbose_name='标题', max_length=32)
    def __str__(self):
        return self.title

class UserInfo(models.Model):
    """员工表"""
    name = models.CharField(verbose_name="姓名", max_length=16)
    password = models.CharField(verbose_name="密码", max_length=16)
    age = models.IntegerField(verbose_name='年龄')
    # django 中做的约束，只能是 1,2
    gender_choices = (
        (1, "男"),
        (2, "女")
    )
    gender = models.SmallIntegerField(verbose_name="性别", choices=gender_choices)
    address = models.CharField(verbose_name='住址', max_length=32)
    # 修改 max_digits 参数为合理值
    salary = models.DecimalField(verbose_name='工资', max_digits=10, decimal_places=2, default=0)
    # create_time = models.DateTimeField(verbose_name='入职时间')#时间为年月日时分秒
    create_time = models.DateField(verbose_name='入职时间')#改成时间为年月日
    depart = models.ForeignKey(to="Department", to_field='id', on_delete=models.CASCADE)

class PhoneNumber(models.Model):
    mobilenumber=models.CharField(verbose_name='手机号码',max_length=32)
    level_choices=(
        (1,"一级"),
        (2, "二级"),
        (3, "三级"),
        (4, "四级"),
    )
    level=models.SmallIntegerField(verbose_name='级别',choices=level_choices,default=1)
    status_choices=(
        (1,'未占用'),
        (2,'已占用'),
    )
    status=models.SmallIntegerField(verbose_name='状态',choices=status_choices)
    price=models.DecimalField(verbose_name='价格',max_digits=5,decimal_places=2,default=10,null=True,blank=True)

class Adminuser(models.Model):
    '''管理员'''
    username=models.CharField(verbose_name='用户名',max_length=32)
    password=models.CharField(verbose_name='密码',max_length=64)

    def __str__(self):
        return self.username

class Task(models.Model):
    """任务"""
    level_choices=(
        (1,"紧急"),
        (2,"重要"),
        (3,"临时"),
    )
    level=models.SmallIntegerField(verbose_name='级别',choices=level_choices,default=1)
    title=models.CharField(verbose_name="标题",max_length=64)
    detail=models.TextField(verbose_name="任务详情",max_length=64)
    user=models.ForeignKey(verbose_name='负责人',to="Adminuser",on_delete=models.CASCADE)#models.CASCADE级联删除

